hexo问题-hexo s本地测试失败,但hexo d部署正常

问题描述:hexo s ,hexo d运行正常,能通过username.github.io查看内容,但在浏览器中无法通过http: //localhost:4000/访问本地服务,显示“404”。

$ hexo s
INFO Start processing
INFO Hexo is running at http://localhost:4000/. Press Ctrl+C to stop.

问题原因:hexo本地测试默认使用的4000端口被占用,可通过“netstat -an|findstr 4000”命令判断

$ netstat -an|findstr 4000
TCP 127.0.0.1:4000 0.0.0.0:0 LISTENING
TCP 127.0.0.1:4000 127.0.0.1:49938 ESTABLISHED
TCP 127.0.0.1:4000 127.0.0.1:49939 ESTABLISHED
TCP 127.0.0.1:4000 127.0.0.1:49940 ESTABLISHED
TCP 127.0.0.1:49938 127.0.0.1:4000 ESTABLISHED
TCP 127.0.0.1:49939 127.0.0.1:4000 ESTABLISHED
TCP 127.0.0.1:49940 127.0.0.1:4000 ESTABLISHED

解决办法:更改本地服务端口

$ hexo server -p 5000
INFO Start processing
INFO Hexo is running at http://localhost:5000/. Press Ctrl+C to stop.
------ 本文结束 ------